#include <iostream>
using namespace std;

int distance(int arr[][4], int n, int test_x, int test_y)
{
	int x[n], y[n];
	int size = 0;
	for (int i = 0; i < n; i++){
		x[i] = arr[i][0] + arr[i][2];
		y[i] = arr[i][1] + arr[i][3];
	}

	for (int i = 0; i < n; i++){
		if(test_x >= arr[i][0] && test_x <= x[i]
			&& test_y >= arr[i][1] && test_y <= y[i]){
			size = i + 1;
		}
		else if(size <= 0){
			size = -1;
		}
	}
	return size;

}


int main(){
	int n;
	cin >> n;
	int arr[n][4];
	int a, b;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < 4; j++){
			cin >> arr[i][j];
		}
	}
	cin >> a >> b;
	int test;
	test = distance(arr,n,a,b);

	cout << test << endl;

	return 0;
}
